JABBA dynamically creates textures for the barrels and items during runtime whenever a resource pack is loaded. It does so to avoid doing these calculations during the render loop.

The basic process it uses is:
1) find the material used for each tier(checks both blocks and items), and get it's average color(*see below)
2) "Grain Merge" that color onto the base texture we wish to color(usually the block borders)
3) Determine and store the "best" contrasting text color(white or black) (*see below)
4) Overlay the other pieces that we wish, skipping any transparent pixels
5) Take the finished texture and upload it to the OpenGL texture sheet

It will only do these calculations once per resource manager reload.

For finding the average color:
- Initialze some totals to 0 for R, G, B
- For each pixel in the source image:
    - if the pixel is not transparent, add it's RGB values to the totals
- Divide each total by the number of added pixels
- Return the totals as the average color

For finding the best contrast text color:
JABBA converts the color to YIQ which weights each component(R, G, or B) based on its "impact" visually and then returns white or black depending.
The actual formula it uses is:
YIQ = ((Red * 299) + (Green * 587) + (Blue * 114)) / 1000;
If the YIQ value is greater than or equal to 128 use black text, otherwise use white text.


IMPORTANT:
the texture sizes must match between:
- The "blank" (this is used to reserve space on the OpenGL texture sheet)
- The colored base/border
- The background pieces(background wood/labels, etc..)


Default MC texture pack calculated colors:
Color for [Oak Wood Planks]: {R: 156, G: 127, B: 78}
Color for [Iron Ingot]: {R: 135, G: 135, B: 135}
Color for [Gold Ingot]: {R: 180, G: 166, B: 44}
Color for [Diamond]: {R: 88, G: 172, B: 158}
Color for [Obsidian]: {R: 20, G: 18, B: 29}
Color for [End Stone]: {R: 221, G: 223, B: 165}
Color for [Emerald]: {R: 46, G: 168, B: 80}
Color for [Slimeball]: {R: 101, G: 154, B: 92}
Color for [Ink Sac]: {R: 49, G: 43, B: 48}
Color for [Rose Red]: {R: 160, G: 32, B: 32}
Color for [Cactus Green]: {R: 59, G: 85, B: 19}
Color for [Cocoa Beans]: {R: 96, G: 57, B: 31}
Color for [Lapis Lazuli]: {R: 36, G: 74, B: 166}
Color for [Purple Dye]: {R: 133, G: 61, B: 172}
Color for [Cyan Dye]: {R: 33, G: 103, B: 132}
Color for [Light Gray Dye]: {R: 144, G: 144, B: 154}
Color for [Gray Dye]: {R: 107, G: 107, B: 107}
Color for [Pink Dye]: {R: 196, G: 122, B: 160}
Color for [Lime Dye]: {R: 95, G: 162, B: 11}
Color for [Dandelion Yellow]: {R: 186, G: 162, B: 32}
Color for [Light Blue Dye]: {R: 100, G: 140, B: 196}
Color for [Magenta Dye]: {R: 170, G: 80, B: 164}
Color for [Orange Dye]: {R: 198, G: 123, B: 35}
Color for [Bone Meal]: {R: 155, G: 155, B: 168}
